package com.hspedu.tankgame05;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;

public class HspTankGame05 extends JFrame {
    MyPanel mp = null;
    Scanner scanner = new Scanner(System.in);
    public HspTankGame05() {
        System.out.println("请输入选择：1.新游戏 2. 继续上局");
        String key = scanner.next();
        mp = new MyPanel(key);
        Thread thread = new Thread(mp);
        thread.start();
        this.add(mp);//游戏区域
        this.setSize(1300,750);
        this.addKeyListener(mp);//让JFrame监听mp的键盘事件
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);

        //响应窗口关闭
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                //System.out.println("窗口关闭");测试
                Record.KeepRecord();
                System.exit(0);
            }
        });
    }
    public static void main(String[] args) {

        HspTankGame05 hspTankGame01 = new HspTankGame05();
    }
}
